﻿using System.Linq;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.Caching.AutoMate.RedisCache;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;

namespace CoreCms.Net.Web.WebApi.Controllers
{
    /// <summary>
    /// 促销活动接口
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PromotionController : ControllerBase
    {
        private readonly ICoreCmsPromotionServices _promotionServices;
        private readonly IRedisOperationRepository _redisOperationRepository;
        private readonly IHttpContextUser _user;
        private readonly IUnitOfWork _unionOfWork;

        /// <summary>
        /// 构造函数
        /// </summary>
        public PromotionController(ICoreCmsPromotionServices promotionServices, IRedisOperationRepository redisOperationRepository, IHttpContextUser user, IUnitOfWork unionOfWork)
        {
            _promotionServices = promotionServices;
            _redisOperationRepository = redisOperationRepository;
            _user = user;
            _unionOfWork = unionOfWork;
        }


        //公共接口====================================================================================================

        #region 获取全局促销列表==================================================
        /// <summary>
        /// 获取全局促销列表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        //[Authorize]
        public async Task<WebApiCallBack> GetPromotionList([FromBody] FMIntId entity)
        {
            var jm = new WebApiCallBack() { msg = "获取失败" };

            var list = await _promotionServices.GetPromotionList(entity.id);
            jm.status = true;
            jm.data = list;
            jm.msg = "获取成功";
            return jm;
        }
        #endregion



        //验证接口====================================================================================================



    }
}
